package com.poetize.plus.controller.admin;

import com.poetize.plus.entity.dto.WebInfoDTO;
import com.poetize.plus.entity.vo.WebInfoVO;
import com.poetize.plus.service.WebInfoService;
import com.poetize.plus.utils.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author zuosy
 * @Date 2024/3/30 8:41
 **/
@Tag(name = "网站信息")
@RestController
@RequestMapping("/admin/web_info")
@RequiredArgsConstructor
public class WebInfoController {

    private final WebInfoService webInfoService;

    @GetMapping
    @Operation(summary = "网站信息详情")
    @PreAuthorize(value = "hasRole('administrator')")
    public R<WebInfoVO> queryWebInfo(){
        return R.ok(webInfoService.queryWebInfo());
    }

    @PostMapping("/updateWebInfo")
    @Operation(summary = "修改网站信息")
    @PreAuthorize(value = "hasRole('administrator')")
    public R<Boolean> updateWebInfo(@RequestBody @Validated WebInfoDTO webInfoDTO){
        return R.ok(webInfoService.updateWebInfo(webInfoDTO));
    }
}
